package com.devilvan.betrice.lol.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.lol.dto.LolBattleHonourDto;
import com.devilvan.betrice.lol.po.LolBattleHonourPo;
import com.devilvan.betrice.lol.service.LolBattleHonourService;
import com.devilvan.betrice.lol.mapper.LolBattleHonourMapper;
import com.devilvan.betrice.lol.repository.LolBattleHonourRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description LOL-对局荣誉信息 业务逻辑类
* @date 2022-09-30
*/
@Service
public class LolBattleHonourServiceImpl extends ServiceImpl<LolBattleHonourMapper, LolBattleHonourPo> implements LolBattleHonourService {
    @Resource(name = "lolBattleHonourRepository")
    private LolBattleHonourRepository lolBattleHonourRepository;

    @Override
    public LolBattleHonourPo saveUpdate(LolBattleHonourDto lolBattleHonourDto) {
        LolBattleHonourPo lolBattleHonourPo = new LolBattleHonourPo();
        UCopy.fullCopy(lolBattleHonourDto, lolBattleHonourPo);
        return lolBattleHonourRepository.saveAndFlush(lolBattleHonourPo);
    }

    @Override
    public List<LolBattleHonourPo> saveUpdateBatch(List<LolBattleHonourDto> list) {
        List<LolBattleHonourPo> lolBattleHonourPoList = UCopy.fullCopyCollections(list, LolBattleHonourPo.class);
        return lolBattleHonourRepository.saveAllAndFlush(lolBattleHonourPoList);
    }
}
